package com.launch.wlfw.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.launch.wlfw.dao.NoticeMapper;
import com.launch.wlfw.pojo.Notice;
import com.launch.wlfw.service.NoticeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName NoticeServiceImpl
 * @Description
 * @Author 29172
 * @Date 2023/7/3 17:55
 */
@Service
public class NoticeServiceImpl implements NoticeService {
    @Resource
    private NoticeMapper noticeMapper;

    @Override
    public PageInfo<Notice> findAllInfo(Notice notice , Integer pageNum , Integer pageSize) {
        PageHelper.startPage(pageNum - 1 , pageSize);
        List<Notice> notices = noticeMapper.findAllInfo(notice);
        return  PageInfo.of(notices);
    }

    /**
     * 添加类型信息
     * @param notice
     * @return
     */

    @Override
    public Integer addInfo(Notice notice) {

        return noticeMapper.addInfo(notice);
    }

    @Override
    public Integer delInfoByID(String ids) {
        return noticeMapper.delInfoByIds(Arrays.asList(ids.split(",")));
    }

    @Override
    public Integer updateInfo(Notice notice) {
        return noticeMapper.updateInfo(notice);
    }

    @Override
    public Notice queryById(long id) {
        return noticeMapper.queryById(id);
    }

    @Override
    public List<Notice> selectAllNotice() {
        return noticeMapper.selectAllNotice();
    }
}
